home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ADA Programming Guide
/
ADA Programming Guide.iso
/
adatutor
/
cppwkbk
/
cppv1-2.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1996-01-30
|
561b
|
36 lines
#define HEADER "C++ Problem 1.2 by Rick Conn using Borland C++"
#include <stdio.h>
struct complex {
double real_part;
double imag_part;
public:
void set(double rp, double ip)
{
real_part = rp;
imag_part = ip;
}
void add_one_to (void)
{
real_part += 1.0;
}
void print (void)
{
printf("(%5.1lfi + %5.1lfj)\n", real_part, imag_part);
}
};
void main(void)
{
printf("%s\n", HEADER);
complex value;
value.set (20.0, -30.0);
value.print();
value.add_one_to();
value.print();
}